package io.github.tuuzed.hydrogen;

import android.database.sqlite.SQLiteDatabase;

public class Delete {
    private String mTableName;
    private String mWhereClause;
    private String[] mWhereArgs;

    public Delete(Class<? extends Model> clazz) {
        mTableName = Hydrogen.getInstance().getTableName(clazz);
    }

    public Delete where(String whereClause, String[] whereArgs) {
        mWhereClause = whereClause;
        mWhereArgs = whereArgs;
        return this;
    }

    public int exec() {
        SQLiteDatabase db = Hydrogen.getInstance().getWritableDatabase();
        int count = db.delete(mTableName, mWhereClause, mWhereArgs);
        db.close();
        return count;
    }
}
